package com.oh.activity;

import java.util.Vector;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import com.oh.database.CargoDao;
import com.oh.database.PreferencesManager;

/**
 * 
 * 程序启动界面
 * 
 * @author Alex.Lu
 *
 */
public class LoaderActivity extends Activity implements Runnable {
    /** Called when the activity is first created. */
	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_loader);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
        Thread thread = new Thread(this);
		thread.start();
    }
    
    @Override
	public void run() {
		// TODO Auto-generated method stub

		try {
			PreferencesManager.getInstance().initPreferences(this);
			
			if(PreferencesManager.getInstance().getISFirst()){
				
				PreferencesManager.getInstance().setPassword();
				Vector<String> searchs = new Vector<String>();
				for(int i=0;i<300;i++){
					searchs.add("product-"+i);
				}
				
				CargoDao.insertSearch(this, searchs);
			}
			
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		Intent intent = new Intent();
		intent.setClass(this, LoginActivity.class);
		startActivity(intent);
		finish();
	}
}